//
//  HomePageBeforeListDetailVC.m
//  YHYRealx
//
//  Created by yanghuiyan on 16/4/20.
//  Copyright © 2016年 yanghuiyan. All rights reserved.
//

#import "HomePageBeforeListDetailVC.h"

@interface HomePageBeforeListDetailVC ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, retain) UITableView *homeTableView;

@property (nonatomic, retain) NSMutableArray *dataSource;

@property (nonatomic, assign) CGFloat cellHeight;



@end

@implementation HomePageBeforeListDetailVC

- (void)dealloc {
    
    [_homeTableView release];
    [_dataModel release];
    [_dataSource release];
    
    [super dealloc];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.dataSource = [NSMutableArray array];
    
    self.view.backgroundColor = [UIColor colorWithRed:248 / 255.0 green:249 / 255.0 blue:240 / 255.0 alpha:1];
    
    _homeTableView.backgroundColor = [UIColor clearColor];
    
    self.homeTableView = [[YHYBaseTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    _homeTableView.frame = YHY;
    [_homeTableView registerClass:[HomePageTableViewCell class] forCellReuseIdentifier:@"homeT"];
    _homeTableView.backgroundColor = [UIColor colorWithRed:248 / 255.0 green:249 / 255.0 blue:240 / 255.0 alpha:1];
    _homeTableView.delegate = self;
    _homeTableView.dataSource = self;
    
    
    [self.view addSubview:_homeTableView];
    
    [_homeTableView release];

    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    // 计算文字高度 调用cell类方法
    _cellHeight = [HomePageTableViewCell heightWithText:_dataModel.hp_content];
    
    // 返回计算后的cell高度
    return _cellHeight + 350;
    
    
}


- (void)setDataModel:(HomePageDataModel *)dataModel {
    if (_dataModel != dataModel) {
        [_dataModel release];
        _dataModel = [dataModel retain];
    }
    [_homeTableView reloadData];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    HomePageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"homeT"];
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    cell.layer.cornerRadius = 5;
    cell.layer.masksToBounds = YES;
    cell.layer.borderWidth = 2;
    cell.layer.borderColor = [UIColor lightGrayColor].CGColor;
    
    cell.dataModel = _dataModel;
    
    return cell;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
